# coding: utf-8

class Student:
    school = '黑马'

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def show(self):
        print('%s:%d' % (self.name, self.age))

    # 静态方法 不能调用实例属性，也不能调用实例方法
    @staticmethod
    def sm(self):
        print(self.show())

    # 静态方法 不能调用实例属性，也不能调用实例方法
    @classmethod
    def cm(cls):
        print(cls.school)

    # 子类及外部可以使用
    def _a(self):
        print('a')

    # 私有方法
    def __b(self):
        print('b')

    @property
    def sex(self):
        return self.__sex

    @sex.setter
    def sex(self, val):
        if val != '男' and val != '女':
            print('性别不匹配')
        else:
            self.__sex = val

    # 方法重写 toString()
    def __str__(self):
        return 'name:%s,age:%d' % (self.name, self.age)


class childrenStudent(Student):
    def __init__(self, name, age, school):
        # 单继承
        super().__init__(name, age)
        # 多继承
        # Student.__init__(self, name, age)
        # Student1.__init__(self, name, age)

        self.school = school


stu = Student('张三', 18)

stu.show()
print(stu.name, stu.age, Student.school)
Student.cm()
# Student.sm()

stu._a()
# stu.__a()

stu.sex = '女'

import copy

# 浅拷贝
stu1 = copy.copy(stu)
print('浅拷贝 copy.copy()', id(stu), id(stu1))

stu2 = copy.deepcopy(stu)
print('深拷贝 copy.deepcopy()', id(stu), id(stu2))

if __name__ == '__main__':
    pass